package com.fishpond.demo.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.fishpond.demo.R
import com.water.fish.anim.MirrorRotationAnim

class DemoActivity : AppCompatActivity() {

    companion object {
        @JvmStatic
        fun jumpTo(context: Context) {
            context.startActivity(Intent(context, DemoActivity::class.java))
        }
    }

    private val ivBall by lazy {
        findViewById<ImageView>(R.id.ivBall).apply {
            setOnClickListener {
                it.startAnimation(MirrorRotationAnim())
            }
        }
    }

    private val mirrorRotationAnim = MirrorRotationAnim()

    private val mirrorRotationAnim2= MirrorRotationAnim(1)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_demo)

        findViewById<View>(R.id.btnRotateLeft).setOnClickListener {
            Log.i("TAG", "onCreate: btnRotateLeft")

            ivBall.startAnimation(mirrorRotationAnim)
        }

        findViewById<View>(R.id.btnRotateRight).setOnClickListener {
            Log.i("TAG", "onCreate: btnRotateRight")
            ivBall.startAnimation(mirrorRotationAnim2)
        }

        findViewById<View>(R.id.btnReset).setOnClickListener {
            Log.i("TAG", "onCreate: btnReset")
            ivBall.clearAnimation()
        }
    }

}